package api

import (
	"github.com/gin-gonic/gin"
	"lesson/api/handler"
	"lesson/consts"
	"lesson/pkg"
)

func Use(c *gin.Engine) {
	api := c.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/login", handler.Login)

		}

		video := api.Group("/video")
		{

			video.POST("/one", handler.OneVideo)

			video.POST("/list", handler.List)

			video.Use(pkg.JWTAuth(consts.JWT_SECRET_KEY))
			video.POST("/add", handler.AddVideo)

			video.POST("/del", handler.DelVideo)

			video.POST("/check", handler.CheckVideo)

			video.POST("/video", handler.UploadVideo)

			video.POST("/update", handler.UpdateVideo)

		}

		chat := api.Group("/chat")
		{
			chat.POST("/sendMessage", handler.SendMessage)

			chat.Use(pkg.JWTAuth(consts.JWT_SECRET_KEY))

			chat.GET("/ws", handler.Chat)

		}
	}
}
